package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.vo.ZsyyParkTicketRenewVo;
import com.ruoyi.system.bo.ZsyyParkTicketRenewQueryBo;
import com.ruoyi.system.bo.ZsyyParkTicketRenewAddBo;
import com.ruoyi.system.bo.ZsyyParkTicketRenewEditBo;
import com.ruoyi.system.service.IZsyyParkTicketRenewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 月票续费记录Controller
 *
 * @author wangghua
 * @date 2021-07-14
 */
@ApiIgnore
@Api(value = "月票续费记录控制器", tags = {"月票续费记录管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/parkTicketRenew")
public class ZsyyParkTicketRenewController extends BaseController {

    private final IZsyyParkTicketRenewService iZsyyParkTicketRenewService;

    /**
     * 查询月票续费记录列表
     */
    @ApiOperation("查询月票续费记录列表")
    @PreAuthorize("@ss.hasPermi('system:parkTicketRenew:list')")
    @GetMapping("/list")
    public TableDataInfo<ZsyyParkTicketRenewVo> list(@Validated ZsyyParkTicketRenewQueryBo bo) {
        return iZsyyParkTicketRenewService.queryPageList(bo);
    }

    /**
     * 导出月票续费记录列表
     */
    @ApiOperation("导出月票续费记录列表")
    @PreAuthorize("@ss.hasPermi('system:parkTicketRenew:export')")
    @Log(title = "月票续费记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<ZsyyParkTicketRenewVo> export(@Validated ZsyyParkTicketRenewQueryBo bo) {
        List<ZsyyParkTicketRenewVo> list = iZsyyParkTicketRenewService.queryList(bo);
        ExcelUtil<ZsyyParkTicketRenewVo> util = new ExcelUtil<ZsyyParkTicketRenewVo>(ZsyyParkTicketRenewVo.class);
        return util.exportExcel(list, "月票续费记录");
    }

    /**
     * 获取月票续费记录详细信息
     */
    @ApiOperation("获取月票续费记录详细信息")
    @PreAuthorize("@ss.hasPermi('system:parkTicketRenew:query')")
    @GetMapping("/{id}")
    public AjaxResult<ZsyyParkTicketRenewVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("id") Long id) {
        return AjaxResult.success(iZsyyParkTicketRenewService.queryById(id));
    }

    /**
     * 新增月票续费记录
     */
    @ApiOperation("新增月票续费记录")
    @PreAuthorize("@ss.hasPermi('system:parkTicketRenew:add')")
    @Log(title = "月票续费记录", businessType = BusinessType.INSERT)
    @RepeatSubmit
    @PostMapping()
    public AjaxResult<Void> add(@Validated @RequestBody ZsyyParkTicketRenewAddBo bo) {
        return toAjax(iZsyyParkTicketRenewService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改月票续费记录
     */
    @ApiOperation("修改月票续费记录")
    @PreAuthorize("@ss.hasPermi('system:parkTicketRenew:edit')")
    @Log(title = "月票续费记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit
    @PutMapping()
    public AjaxResult<Void> edit(@Validated @RequestBody ZsyyParkTicketRenewEditBo bo) {
        return toAjax(iZsyyParkTicketRenewService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除月票续费记录
     */
    @ApiOperation("删除月票续费记录")
    @PreAuthorize("@ss.hasPermi('system:parkTicketRenew:remove')")
    @Log(title = "月票续费记录" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
                                       @PathVariable Long[] ids) {
        return toAjax(iZsyyParkTicketRenewService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
